<#assign dtoClass = entity + "DTO">
<#assign dtoParam = entity?substring(0,1)?lower_case + entity?substring(1) + "DTO">
<#assign entityParam = entity?substring(0,1)?lower_case + entity?substring(1)>
<#assign serviceParam = table.serviceName?substring(0,1)?lower_case + table.serviceName?substring(1)>
<#assign tableComment = table.comment!?substring(0, table.comment!?length - 1)>
package ${package.Controller};

import ${dtoPackage}.${dtoClass};
import ${package.Service}.${table.serviceName};

import cn.com.blueInfo.bpm.common.service.ValidationGroups;
import cn.com.blueInfo.utils.result.ResultInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ${table.comment!} 前端控制器
 * @author ${author}
 * @since ${date}
 */
@Tag(name = "${tableComment} 接口")
@RestController
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
public class ${table.controllerName} {

    @Autowired
    private ${table.serviceName} ${serviceParam};

    /**
    * 新建${tableComment}
    * @param ${dtoParam} ${tableComment}参数
    * @return ResultInfo
    */
    @Operation(summary = "新增${tableComment}")
    @PostMapping("/${entityParam}-info")
    public ResultInfo create${entity}(
            @Validated(ValidationGroups.Create.class) @RequestBody ${dtoClass} ${dtoParam}) {
        return ${serviceParam}.add${entity}(${dtoParam});
    }

    /**
    * 根据ID删除${tableComment}
    * @param ${entityParam}Id ${tableComment}ID
    * @return ResultInfo
    */
    @Operation(summary = "根据ID删除${tableComment}")
    @DeleteMapping("/${entityParam}-info/{${entityParam}Id}")
    public ResultInfo delete${entity}ById(
            @Parameter(name = "ID") @PathVariable String ${entityParam}Id) {
        return ${serviceParam}.remove${entity}(${entityParam}Id);
    }

    /**
    * 根据ID全量更新${tableComment}
    * @param ${entityParam}Id ${tableComment}ID
    * @param ${dtoParam} ${tableComment}参数
    * @return ResultInfo
    */
    @Operation(summary = "根据ID全量更新${tableComment}")
    @PutMapping("/${entityParam}-info/{${entityParam}Id}")
    public ResultInfo update${entity}Full(
            @Parameter(name = "ID") @PathVariable String ${entityParam}Id,
            @Validated(ValidationGroups.Update.class) @RequestBody ${dtoClass} ${dtoParam}) {
        ${dtoParam}.setId(Long.valueOf(${entityParam}Id));
        return ${serviceParam}.modify${entity}(${dtoParam});
    }

    /**
    * 根据ID部分更新${tableComment}
    * @param ${entityParam}Id ${tableComment}ID
    * @param ${dtoParam} ${tableComment}参数
    * @return ResultInfo
    */
    @Operation(summary = "根据ID部分更新${tableComment}")
    @PatchMapping("/${entityParam}-info/{${entityParam}Id}")
    public ResultInfo update${entity}Partial(
            @Parameter(name = "ID") @PathVariable String ${entityParam}Id,
            @Validated(ValidationGroups.UpdatePartial.class) @RequestBody ${dtoClass} ${dtoParam}) {
        ${dtoParam}.setId(Long.valueOf(${entityParam}Id));
        return ${serviceParam}.modify${entity}Partial(${dtoParam});
    }

    /**
    * 根据ID查询${tableComment}
    * @param ${entityParam}Id ${tableComment}ID
    * @return ResultInfo
    */
    @Operation(summary = "根据ID查询${tableComment}")
    @GetMapping("/${entityParam}-info/{${entityParam}Id}")
    public ResultInfo get${entity}ById(
            @Parameter(name = "ID") @PathVariable String ${entityParam}Id) {
        return ${serviceParam}.query${entity}ById(${entityParam}Id);
    }

    /**
    * 分页查询${tableComment}
    * @param ${dtoParam} ${tableComment}参数
    * @return ResultInfo
    */
    @Operation(summary = "分页查询${tableComment}")
    @GetMapping("/${entityParam}-infos")
    public ResultInfo get${entity}Page(
            @Validated(ValidationGroups.Select.class) ${dtoClass} ${dtoParam}) {
        return ${serviceParam}.query${entity}Page(${dtoParam});
    }

}
